package org.bookie.mtest;


import java.util.Collection;

import org.bookie.mtest.framework.Application;
import org.bookie.mtest.framework.Page;
import org.testng.Assert;
import org.testng.annotations.Test;

@Test
public class NavigationTest {

	private static final String ADMIN_PASSWORD = "test";
	private static final String ADMIN_EMAIL = "homer@freebookie.org";

	public void testHomePage() throws Exception {
		Application app = new Application();
		app.start();
	}
	
	public void testMenuNavigation() throws Exception {
		Application app = new Application();
		Page page = app.start();
		Collection<String> mainMenuItems = page.getMainMenuItems();
		Assert.assertEquals(mainMenuItems.size(), 4);
		for (String itemName : mainMenuItems) {
			page.clickOnLinkWithText(itemName);
		}
	}
	
	public void testAdminMenuNavigation() throws Exception {
		Application app = new Application();
		Page page = app.start();
		Collection<String> menuAnonym = page.getMainMenuItems();
		page.login(ADMIN_EMAIL, ADMIN_PASSWORD);
		Collection<String> menuAdmin = page.getMainMenuItems();
		Assert.assertFalse(menuAnonym.equals(menuAdmin), "Admin menu haven't been changed");
		for (String itemName : menuAdmin) {
			page.clickOnLinkWithText(itemName);
		}
	}
	
}
